import {Component, Input, OnInit} from "@angular/core";
import {FileInfo} from "@shared/models/FileInfo";
import {PermissionDetail} from "@shared/models/Permission";
import {BBYUtils} from "@shared/utils/BBYUtils";

@Component({
  selector: 'bby-permission-request',
  template:
    `
      <div >
        选择的文件：【{{namesStr}}】
      </div>
      <div >
        留言：
        <nz-textarea-count [nzMaxCharacterCount]="100">
          <textarea style="max-height: 98px" rows="4" [maxlength]="100" nz-input [(ngModel)]="message"></textarea>
        </nz-textarea-count>
      </div>
      <div >
        请勾选您想要获得的权限：
      </div>
      <div style="margin: 10px 0px">
        <label [nzDisabled]="isFile||currentDetail.create" nz-checkbox [(ngModel)]="detail.create">创建</label>
        <label [disabled]="currentDetail.copy" nz-checkbox [(ngModel)]="detail.copy">复制</label>
        <label [disabled]="currentDetail.move" nz-checkbox [(ngModel)]="detail.move">移动</label>
        <label [disabled]="currentDetail.delete" nz-checkbox [(ngModel)]="detail.delete">删除</label>
        <label [disabled]="currentDetail.download" nz-checkbox [(ngModel)]="detail.download">下载</label>
        <label [disabled]="currentDetail.view" nz-checkbox [(ngModel)]="detail.view">可见</label>
        <label [disabled]="currentDetail.edit" nz-checkbox [(ngModel)]="detail.edit">修改</label>
        <br />
      </div>
    `
})
export class PermissionRequest implements OnInit{
  @Input()
  detail:PermissionDetail=new PermissionDetail()

  @Input()
  isFile = false

  @Input()
  names:string[]=[]
  message=''
  namesStr=''
  currentDetail:PermissionDetail = this.detail
  ngOnInit(): void {
    this.currentDetail = BBYUtils.clone(this.detail)
    this.namesStr=this.names.join(',')
  }
}
